import React from 'react'
import Sun from './Sun'
import { useSelector, useDispatch } from 'react-redux'
import userSlice from '../store/modules/userSlice'

export default function Child() {
  const user = useSelector((state) => state.user)
  const dispatch = useDispatch()

  const clickFn = () => {
    console.log(userSlice.actions.updateUsername('窦傲杰'))
    dispatch(userSlice.actions.updateUsername('窦傲杰'))
  }
  return (
    <div>
      <h5>
        Child-{user.username}-{user.token}
        <button onClick={clickFn}>你是谁</button>
      </h5>
      <Sun></Sun>
    </div>
  )
}
